# The American Viewer: Political Consequences of Entertainment Media
# Eunji Kim and Shawn Patterson Jr 
# American Political Science Review 
# Replication File [Appendix C Figure C1]


# load appendix_figurec1 data 
data <- read.csv("appendix_figurec1.csv")


data <- data %>%  
  mutate(DateStart = substr(Dates, 1, 10) %>% as.Date(format="%m/%d/%Y"))
data$Issue <- factor(data$Issue, levels = c(  'real estate', 'real estate and apprentice', 'apprentice'))

lexisnexis <- ggplot(data, aes(x = DateStart, y = N, fill = Issue)) + 
  geom_bar(stat = "identity", color="black", size=0.1) +
  scale_fill_manual(values = c( "grey66", "grey33", "#8a0002" )) +
  scale_x_date(date_breaks = "months" , date_labels = "%b'%y", limits = c(as.Date("2015-06-16"), as.Date("2016-11-10")), expand = c(0.01, 0)) +  
  scale_y_continuous(labels=comma, breaks=c(seq(0, 2500, 500))) +  
  geom_vline(xintercept = as.Date("2016-07-06"), linetype="dotted", color = "black", size=0.5) +  
  #geom_vline(xintercept = as.Date("2016-11-09"), linetype="dashed", color = "black", size=0.5) +  
  labs(y = "Number of Articles") +  
  theme_classic() +  
  theme(axis.title.x = element_blank(),        
        axis.title.y = element_text(color="black", size=10, face="bold"),        
        axis.text.x = element_text(color= "black", size=7, face="bold"),        
        axis.text.y = element_text(color= "black", size=9, face="bold"),        
        legend.position = "bottom",     
        legend.title= element_blank(),
        plot.margin = margin(0.5, 0.5, 0.5, 0.25, "cm")) +
  annotate(geom="label", label = "Trump wins the\nRepublican Nomination", x=as.Date("2016-07-06"), y=2500, hjust=0.5, fontface=2, size=2)   

lexisnexis
